Electronic device for contention detection of bidirectional bus and related method

ABSTRACT

An electronic device of detecting contention of a bidirectional bus for avoiding failing to drive a bidirectional bus due to bus contention includes: an output terminal, an input terminal and a data output unit, a timing comparing controller and a comparing unit. The output terminal is coupled to the bidirectional bus and used for outputting a data output signal to the bidirectional bus. The input terminal is coupled to the output terminal and the bidirectional bus and used for receiving a data reception signal from the bidirectional bus. The data output unit is used for providing the data output signal. The timing comparing controller is used for generating a timing comparison signal according to the data output signal. The comparing unit is used for comparing the data reception signal with the data output signal according to the timing comparison signal to determine a contention state of the bidirectional bus.

BACKGROUND OF THE INVENTION

1. Field of the Invention

The present invention relates to an electronic device and related method for detection of bus contention, and more particularly, to an electronic device of detecting contention of a bidirectional bus and related method.

2. Description of the Prior Art

A bus is a transmission interface capable of transmitting data between two electronic devices or among a plenty of electronic devices. In general, buses are classified with unidirectional and a bidirectional types. The unidirectional bus is allowed to transmit data from an X device to a Y device, but not from the Y device to the X device. The bidirectional bus is allowed to exchange data between the X and Y devices. In implementation of a chip, employment of the bidirectional bus interface has a need of fewer pins than employment of the unidirectional bus.

Please refer to FIG. 1, which is a schematic diagram of a master-slave system 10 according to the prior art. The master-slave system 10 employs a half-duplex bidirectional bus 12 for data transmission between a master device 14 and a slave device 16. The master device 14 includes a transmitter 142 and a receiver 144, whereas the slave device 16 includes a transmitter 162 and a receiver 164. In normal situation, the receiver 164 performs data receptions and no data is allowed to be transmitted from the transmitter 162 when the transmitter 142 outputs a data signal S1. Similarly, the receiver 144 performs data reception and no data is allowed to be transmitted by the transmitter 142 when the transmitter 162 outputs a data signal S2. That is, only one transmitting side is allowed to drive the bidirectional bus 12 at one time. As a result, the master device 14 and the slave device 16 have to contend for every transmission opportunity. However, the bidirectional bus 12 is likely to be simultaneously driven by the master device 14 and the slave device 16 due to occurrence of a signal transition during bus contention. This causes an operating failure in the bidirectional bus 12. For example, when the data signals S1 and S2 are simultaneously outputted to the bidirectional bus 12 as can be seen from FIG. 1, the transitions of the data signals S1 and S2 cause signal cancelling, thereby resulting in data reception failures in the receivers 164 and 144.

SUMMARY OF THE INVENTION

The present invention therefore provides an electronic device of detecting contention of a bidirectional bus and related method that can avoid failing to output data to the bidirectional bus due to transmission collision.

The present invention discloses an electronic device of detecting contention of a bidirectional bus. The electronic device includes an output terminal, an input terminal, a data output unit, a timing comparing controller and a comparing unit. The output terminal is coupled to the bidirectional bus and used for outputting a data output signal to the bidirectional bus. The input terminal is coupled to the output terminal and the bidirectional bus and used for receiving a data reception signal from the bidirectional bus. The data output unit is used for providing the data output signal. The timing comparing controller is used for generating a timing comparison signal according to the data output signal. The comparing unit is coupled to the input terminal, the data output unit, and the timing comparing controller and used for comparing the data reception signal with the data output signal according to the timing comparison signal to determine a contention state of the bidirectional bus.

The present invention further discloses a method of detecting contention of a bidirectional bus used for transmitting a data output signal and receiving a data reception signal. The method includes generating a timing comparison signal according to the data output signal before the bidirectional bus transmits the data output signal, and then comparing the data reception signal with the data output signal according to the timing comparison signal to determine a contention state of the bidirectional bus.

The present invention further discloses an electronic device of detecting contention of a bidirectional bus. The electronic device includes an output terminal, an input terminal, a data output unit, a sampling timing generator, a sampling unit, a detection timing generator and a comparing unit. The output terminal is coupled to the bidirectional bus and used for outputting a data output signal to the bidirectional bus. The input terminal is coupled to the output terminal and the bidirectional bus, and used for receiving a data reception signal from the bidirectional bus. The data output unit is used for providing the data output signal. The sampling timing generator is coupled to the data output unit and used for generating a sampling timing signal according to the data output signal. The sampling unit is coupled to the data output unit and the sampling timing generator and used for sampling the data output signal according to the sampling timing signal to generate a sample data signal. The detection timing generator is coupled to the data output unit and used for generating a detection timing signal according to the data output signal. The comparing unit is coupled to the input terminal, the sampling unit, and the detection timing generator and used for comparing the data reception signal with the sample data signal according to the detection timing signal, to determine a contention state of the bidirectional bus.

The present invention further discloses a method of detecting contention of a bidirectional bus used for transmitting a data output signal and receiving a data reception signal. The method includes generating a sampling timing signal according to the data output signal, sampling the data output signal according to the sampling timing signal, to generate a sample data signal, generating a detection timing signal according to the data output signal, and then comparing the data reception signal with the sample data signal according to the detection timing signal, to determine a contention state of the bidirectional bus.

These and other objectives of the present invention will no doubt become obvious to those of ordinary skill in the art after reading the following detailed description of the preferred embodiment that is illustrated in the various figures and drawings.

BRIEF DESCRIPTION OF THE DRAWINGS

FIG. 1 is a schematic diagram of a master-slave system according to the prior art.

FIG. 2 is a schematic diagram of an electronic device according to a first embodiment of the present invention.

FIG. 3 is a flowchart of a process according to an embodiment of the present invention.

FIG. 4 is a schematic diagram of related signal waveforms of the electronic device according to FIG. 2.

FIG. 5 is a schematic diagram of an electronic device according to a second embodiment of the present invention.

FIG. 6 is a schematic diagram of related signal waveforms of the electronic device according to FIG. 5.

FIG. 7 is a flowchart of a process according to an embodiment of the present invention.

DETAILED DESCRIPTION

Please refer to FIG. 2, which is a schematic diagram of an electronic device 20 according to a first embodiment of the present invention. In this embodiment, the electronic device 20 is installed in a slave device and responsible for detecting bus contention on bidirectional links 22 and 24 of a half-duplex bidirectional bus. The electronic device 20 includes output terminals OUT1 and OUT2, input terminals IN1 and IN2, output buffers 200 and 202, input buffers 210 and 212, a timing generator 220, a data decoder 230, a data input unit 240, a data output unit 242, a timing comparing controller 250 and a comparing unit 260. The input terminals IN1 and IN2 are adapted to receive data reception signals SRP and SRN from the bidirectional links 22 and 24 respectively. The input buffers 210 and 212, both preferably a Schmitt trigger, determine signal levels of the data reception signals SRP and SRN according to a plurality of predetermined signal levels for signal equalization. The signals transmitted on the bidirectional links 22 and 24, irrespective of the signals received or outputted by the electronic device 20, are complementary signals. That is, one bidirectional link transmits a “0” data signal, and the other bidirectional link transmits a “1” data signal. With this complementary transmission feature, the timing generator 220 performs exclusive-OR (XOR) logic operation to the data reception signals SRP and SRN to obtain an embedded clock signal CLK used as a system clock of the electronic device 20. In addition, the data decoder 230 decodes instructions embedded in the data reception signals SRP and SRN according to the clock signal CLK. The data input unit 240 transfers the decoded instructions to back-end devices, such as a central processing unit. The data output unit 242 provides data output signals SOP and SON sent out by the back-end devices. The output buffers 200 and 202 temporarily store the data output signals SOP and SON respectively. The output terminals OUT1 and OUT2 outputs the data output signals SOP and SON to the bidirectional links 22 and 24.

To detect bus contention, the data output unit 242 generates a transition signal ST when detecting a signal transition of either the data output signal SOP or SON. The timing comparing controller 250 preferably includes delay units for delaying the transition signal ST to generate a timing comparison signal SCT. The comparing unit 260 compares the data reception signal SRP with the data output signal SOP and also compares the data reception signal SRP with the data output signal SOP according to the timing comparison signal SCT to determine contention states of the bidirectional links 22 and 24 respectively. The contention state of the bidirectional links 22 is determined as below for example. When the data output signal SOP is outputted to the bidirectional links 22, the related contention state is determined to “no collision” if a waveform of the data reception signals SRP received by the comparing unit 260 is identical with a waveform of the data output signal SOP since the output terminal OUT1 is coupled to the input terminal IN1. On the contrary, the contention state is determined to “collision” if the waveform of the data reception signals SRP is different from the waveform of the data output signal SOP. The waveform difference is incurred because the data output signal SOP on the bidirectional links 22 is further driven by a remote device, such as a master device.

Please refer to FIG. 3, which illustrates a flowchart of a process 30 according to an embodiment of the present invention. The process 30 is used in the electronic device 20 for detecting the contention state of the bidirectional links 22 transmitting the data output signal SOP or receiving data reception signal SRP. The process 30 includes the following steps:

Step 300: Start.

Step 302: Generate the transition signal ST when a signal transition of the data output signal SOP occurs.

Step 304: Generate the timing comparison signal SCT, whose timing is delayed to fall behind the transition signal ST for a delay time T1, according to the transition signal ST.

Step 306: Compare the data reception signal SRP with the data output signal SOP according to the timing comparison signal SCT to determine the contention state of the bidirectional bus 22.

Step 308: End.

According to the process 30, the embodiment of the present invention generates the transition signal ST when the signal transition of the data output signal SOP occurs, and thereby generates the timing comparison signal SCT for comparing a logic state of the data reception signal SRP with the logic state of the data output signal SOP, so as to determine the contention state of the bidirectional bus 22. The further detailed operation of the process 30 can be referred by the above description about the electronic device 20 and is omitted herein. In addition, the process 30 is applicable for detection of the contention state of bidirectional links 24 as well.

Please refer to FIG. 4, which is a schematic diagram of related signal waveforms of the electronic device 20. The related waveforms from top to bottom are the data output signals SOP and SON, and the clock signal CLK obtained by performing XOR operation to the data output signals SOP and SON. In FIG. 4, a signal transition of the data output signal SOP at time T2 is used as an example for explanation of the concept of the present invention. When the data output signal SOP transits at time T2, the data output unit 244 generates the transition signal ST. The timing comparing controller 250 generates the timing comparison signal SCT a delay time T1 after the time T2 for signal comparison. Preferably, the delay time T1 is less than time different of two consecutive signal transitions, such as the time difference of the time T2 and the time T3.

As can been seen from the above, the embodiment of the present invention firstly detects the transition of the data output signal and then compares the data reception signal with the data output signal a predetermined delay time after the transition.

Please note that the way the timing comparing controller 250 generates the timing comparison signal SCT is not intended to limit the scope of the present invention, but to accord with principles and features of the claimed present invention. The timing comparing controller 250 can also generate the timing comparison signal SCT according to other features of the data output signal, such as signal level differences or a processed data output signal, so as to appropriately control the comparing timing of the comparing unit 260.

Please refer to FIG. 5, which is a schematic diagram of an electronic device 50 according to a second embodiment of the present invention. Parts of elements in the electronic device 50 are identical with the corresponding elements in the electronic device 20, and thereby the associated detailed descriptions about operations are omitted. The electronic device 50 is also used for detecting contentions of the bidirectional links 22 and 24 and includes output terminals OUT1 and OUT2, input terminals IN1 and IN2, output buffers 200 and 202, input buffers 210 and 212, a timing generator 220, a data decoder 230, a data input unit 240, a data output unit 500, a sampling timing generator 510, a sampling unit 520, a detection timing generator 530 and a comparing unit 540. The data output unit is used for providing the data output signals SOP and SON for the sampling timing generator 510, the sampling unit 520, and the detection timing generator 530. The sampling timing generator 510 generates a sampling timing signal S_SMTP according to a signal transition of the data output signal SOP and also generates a sampling timing signal S_SMTN according to a signal transition of the data output signal SON. The sampling unit 520 samples the data output signal SOP/SON according to the sampling timing signal S_SMTP/ S_SMTN to generate and provide sample data signals SOP_SM/SON_SM for the comparing unit 540. The detection timing generator 530 generates a detection timing signal S_DTP/S_DTN when the transition of the data output signal SOP/SON occurs. The comparing unit 540 compares the data reception signal SRP/SRN with the sampling data signal SOP_SM/SON_SM according to the detection timing signal S_DTP/S_DTN, to determine contention states of the bidirectional links 22 and 24. Please note that, for correct comparison, the comparing unit 540 neglects the detection timing signals generated in the first transitions of the data output signals SOP and SON.

Please refer to FIG. 6, which is a schematic diagram of related signal waveforms of the electronic device 50. The related waveforms from top to bottom are the data output signals SOP and SON, signals of the output terminals OUT1 and OUT2, the sampling timing signals S_SMTP and S_SMTN, the sampling signals SOP_SM and SON_SM, and the detection timing signals S_DTP and S_DTN. Due to load effect, the waveforms of the data output signals SOP and SON outputted by the output buffers 200 and 202 become the signal waveforms of the output terminals OUT1 and OUT2 respectively. Take the signals corresponding to the bidirectional link 22 for example. When the data output signal SOP transits, the sampling timing signal S_SMTP is generated for sampling of the data output signal SOP, thereby generating the sampling signal SOP_SM. On the other hand, each time the data output signal SOP transits, the detection timing signal S_DTP is generated for comparison of the data reception signal SRP and the sampling signal SOP_SM. Furthermore, the embodiment of the present invention neglects the detection timing signals S_DTP and S_DTN generated according to the first transition of the data output signals SOP and SON, and thus no detection timing signals S_DTP and S_DTN are generated in FIG. 6 at the corresponding first signal transitions.

Similar to the contention principle of the electronic device 20, the contention state of the bidirectional link 22 is determined to “no contention” when the data reception signal SRP and the sampling signal SOP_SM are detected having the same waveforms during a certain clock cycle.

As shown in FIG. 6, for the data output signal having a rise-fall waveform, the electronic device 50 performs sampling when detecting a rising edge of the data output signal and then compares the data reception signal with the sampling signal at the falling edge.

Please refer to FIG. 7, which illustrates a flowchart of a process 70 according to an embodiment of the present invention. The process 70 is used in the electronic device 50 for detecting the contention state of the bidirectional links 22 transmitting the data output signal SOP or receiving data reception signal SRP. The process 70 includes the following steps:

Step 700: Start.

Step 702: Generate the sampling timing signal S_SMTP when a signal transition of the data output signal SOP occurs.

Step 704: Sample the data output signal SOP according to the sampling timing signal S_SMTP to generate the sample data signal SOP_SM.

Step 706: Generate the detection timing signal S_DTP when next signal transition of the data output signal SOP occurs.

Step 708: Compare the data reception signal SRP with the sample data signal SOP_SM according to the detection timing signal S_DTP to determine the contention state of the bidirectional link 22.

Step 710: End.

According to the process 70, the embodiment of the present invention generates the sampling timing signal S_SMTP when the signal transition of the data output signal SOP occurs, and thereby samples the data output signal SOP to generate the sample data signal SOP_SM. When next signal transition of the data output signal SOP occurs, the embodiment of the present invention generates the detection timing signal S_DTP controlling the time of comparing the data reception signal SRP with the sample data signal SOP_SM, so as to determine the contention state. The further detailed operation of the process 70 can be referred by the above description about the electronic device 50 and is omitted herein. In addition, the process 70 is applicable for detection of the contention state of bidirectional links 24 as well.

In conclusion, the first embodiment of the present invention detects the bus contention state a delay time later after any signal transition of the data output signal occurs. The second embodiment of the present invention samples the data output signal at the first signal transition of two consecutive signal transitions of the data output signal and then perform signal comparison at the second signal transition to detect the bus contention state. Therefore, the embodiments of the present invention avoid bus driving failure caused by contentions.

Those skilled in the art will readily observe that numerous modifications and alterations of the device and method may be made while retaining the teachings of the invention. 

1. An electronic device of detecting contention of a bidirectional bus, the electronic device comprising: an output terminal coupled to the bidirectional bus, for outputting a data output signal to the bidirectional bus; an input terminal coupled to the output terminal and the bidirectional bus, for receiving a data reception signal from the bidirectional bus; a data output unit for providing the data output signal; a timing comparing controller for generating a timing comparison signal according to the data output signal; and a comparing unit coupled to the input terminal, the data output unit and the timing comparing controller, for comparing the data reception signal with the data output signal according to the timing comparison signal to determine a contention state of the bidirectional bus.
 2. The electronic device of claim 1 further comprising an input buffer coupled between the input terminal and the comparing unit, for determining a signal level of the data reception signal according to the plurality of predetermined signal levels.
 3. The electronic device of claim 1 further comprising an output buffer coupled between the output terminal and the data output unit, for temporarily storing the data output signal.
 4. The electronic device of claim 1, wherein the data output unit further detects a transition of the data output signal to generate a transition signal.
 5. The electronic device of claim 4, wherein the timing comparing controller comprises a delay unit for delaying the transition signal for a delay time to generate the timing comparison signal.
 6. The electronic device of claim 5, wherein the delay time is less than time difference between the transition of the data output signal and a next transition of the transition.
 7. The electronic device of claim 1, wherein the bidirectional bus is a half-duplex bidirectional bus.
 8. A method of detecting contention of a bidirectional bus used for transmitting a data output signal and receiving a data reception signal, the method comprising: generating a timing comparison signal according to the data output signal before the bidirectional bus transmits the data output signal; and comparing the data reception signal with the data output signal according to the timing comparison signal to determine a contention state of the bidirectional bus.
 9. The method of claim 8 further comprising determining a signal level of the data reception signal according to a plurality of predetermined signal levels before comparing the data reception signal with the data output signal according to the timing comparison signal.
 10. The method of claim 8 further comprising temporarily storing the data output signal before the bidirectional bus transmits the data output signal.
 11. The method of claim 8 further comprising detecting a transition of the data output signal to generate a transition signal.
 12. The method of claim 11 further comprising delaying the transition signal for a delay time to generate the timing comparison signal before the bidirectional bus transmits the data output signal.
 13. The method of claim 12, wherein the delay time is less than time difference between the transition of the data output signal and a next transition of the transition.
 14. The method of claim 8, wherein the bidirectional bus is a half-duplex bidirectional bus.
 15. An electronic device of detecting contention of a bidirectional bus, the electronic device comprising: an output terminal coupled to the bidirectional bus, for outputting a data output signal to the bidirectional bus; an input terminal coupled to the output terminal and the bidirectional bus, for receiving a data reception signal from the bidirectional bus; a data output unit for providing the data output signal; a sampling timing generator coupled to the data output unit, for generating a sampling timing signal according to the data output signal; a sampling unit coupled to the data output unit and the sampling timing generator, for sampling the data output signal according to the sampling timing signal, to generate a sample data signal; a detection timing generator coupled to the data output unit, for generating a detection timing signal according to the data output signal; and a comparing unit coupled to the input terminal, the sampling unit and the detection timing generator, for comparing the data reception signal with the sample data signal according to the detection timing signal, to determine a contention state of the bidirectional bus.
 16. The electronic device of claim 15 further comprising an input buffer coupled between the input terminal and the comparing unit, for determining a signal level of the data reception signal according to the plurality of predetermined signal levels.
 17. The electronic device of claim 15 further comprising an output buffer coupled between the output terminal and the data output unit, for temporarily storing the data output signal.
 18. The electronic device of claim 15, wherein the detection timing generator generates the detection timing signal according to transitions of the data output signal.
 19. The electronic device of claim 18, wherein the comparing unit neglects the detection timing signal generated according to a first transition of the data output signal.
 20. The electronic device of claim 15, wherein the bidirectional bus is a half-duplex bidirectional bus.
 21. A method of detecting contention of a bidirectional bus used for transmitting a data output signal and receiving a data reception signal, the method comprising: generating a sampling timing signal according to the data output signal; sampling the data output signal according to the sampling timing signal, to generate a sample data signal; generating a detection timing signal according to the data output signal; and comparing the data reception signal with the sample data signal according to the detection timing signal, to determine a contention state of the bidirectional bus.
 22. The method of claim 21 further comprising determining a signal level of the data reception signal according to the plurality of predetermined signal levels before comparing the data reception signal with the sample data signal according to the detection timing signal.
 23. The method of claim 21 further comprising temporarily storing the data output signal before the bidirectional bus transmits the data output signal.
 24. The method of claim 21, wherein the step of generating the detection timing signal according to the data output signal comprises: generating the detection timing signal according to transitions of the data output signal.
 25. The method of claim 24, wherein the step of generating the detection timing signal according to transitions of the data output signal further comprises: neglecting the detection timing signal generated according to a first transition of the data output signal.
 26. The method of claim 21, wherein the bidirectional bus is a half-duplex bidirectional bus. 